package cj.web.portal.service;

import java.util.ArrayList;
import java.util.List;

import net.paoding.rose.web.var.Model;
import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cj.web.admin.constants.ColumnsEnum;
import cj.web.admin.constants.Constants;
import cj.web.kly.constants.SubjectTypeEnum;
import cj.web.kly.domain.GroupDep;
import cj.web.kly.domain.News;
import cj.web.kly.domain.Subject;
import cj.web.portal.dao.GroupDepVoDAO;
import cj.web.portal.dao.NewsVoDAO;
import cj.web.portal.dao.SubjectVoDAO;

@Service
public class HomeService {

	@Autowired
    private NewsVoDAO newsVoDAO;
	@Autowired
    private SubjectVoDAO subjectVoDAO;
	@Autowired
    private GroupDepVoDAO groupDepVoDAO;
	
	public Model getHomeModel(Model model,String news_columnsid,String announcement_columnsid,
			String majorproject_columnsid,String honoraryawards_columnsid,String gjjpt_columnsid,
			String ysjpt_columnsid,String partyaffairs_columnsid,
			String researchactivity_columnsid,String industrynews_columnsid,
			String academiccommunication_columnsid,String sngzh_columnsid){
		//置顶 头条
		List<News> toplis = newsVoDAO.queryTop(0, 5);
		
		//新闻动态 columnsId 14,15,16,17
		List<News> news = newsVoDAO.queryHomeLis(news_columnsid, 0, 11);
		
		//公告栏 columnsId 20
		List<News> announcement = newsVoDAO.queryHomeLis(announcement_columnsid, 0, 8);
		
		//重大项目 columnsId 28,29
		List<News> majorProject = newsVoDAO.queryHomeLis(majorproject_columnsid, 0, 8);
		
		//荣誉奖项 columnsId 11
		List<News> honoraryAwards = newsVoDAO.queryHomeLis(honoraryawards_columnsid, 0, 10);
		
		//专题
		List<Subject> subjectlisBFD = subjectVoDAO.querySubject(SubjectTypeEnum.TYPE_0.getValue(), 0, 4);//不浮动
		List<Subject> subjectlisFD = subjectVoDAO.querySubject(SubjectTypeEnum.TYPE_1.getValue(), 0, 1);//浮动
		
		//国家级平台,省部级平台 groupId 14,15
		List<GroupDep> sbjptlis = groupDepVoDAO.queryNameByGroupId(gjjpt_columnsid);
		
		//院所平台 groupId 16
		List<GroupDep> ysptlis = groupDepVoDAO.queryNameByGroupId(ysjpt_columnsid);
		
		//党群活动 columnsId 18,19
		List<News> partyAffairs = newsVoDAO.queryHomeLis(partyaffairs_columnsid, 0, 8);
		//科研进展 columnsId 15
		List<News> researchActivity = newsVoDAO.queryHomeLis(researchactivity_columnsid, 0, 8);
		//行业动态 columnsId 17
		List<News> industryNews = newsVoDAO.queryHomeLis(industrynews_columnsid, 0, 8);
		//学术交流 columnsId 16
		List<News> academicCommunication = newsVoDAO.queryHomeLis(academiccommunication_columnsid, 0, 8);
		//所内公众号
		List<News> sngzhlis = newsVoDAO.queryBycolumnsIdForContent(sngzh_columnsid,0,1);
		
		model.add("toplis", toplis);
		model.add("news", news);
		model.add("announcement", announcement);
		model.add("majorProject", majorProject);
		model.add("honoraryAwards", honoraryAwards);
		model.add("subjectlisFD", subjectlisFD);
		model.add("subjectlis", subjectlisBFD);
		model.add("sbjptlis", sbjptlis);
		model.add("ysptlis", ysptlis);
		
		model.add("partyAffairs", partyAffairs);
		model.add("researchActivity", researchActivity);
		model.add("industryNews", industryNews);
		model.add("academicCommunication", academicCommunication);
		model.add("sngzhlis", sngzhlis);
		return model;
	}
}